package demo1;

import java.io.File;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 38917
 * Date: 2025-03-11
 * Time: 22:30
 */
public class mkdirDemo1 {
    public static void main(String[] args) {
        File file1 = new File("./xxx");
        File file2 = new File("./aaa/bbb/ccc");
        //创建单级目录
        System.out.println(file1.mkdir());
        //创建多级目录
        System.out.println(file2.mkdirs());
        //判断该引用指向的是不是目录
        System.out.println(file1.isDirectory());
        System.out.println(file2.isDirectory());

        //reNameTo
        //用法一：重命名
        //将file3指向的ddd目录重命名为file4指向的fff目录
        //要求xxx目录必须存在，fff目录不存在
        /*File file4 = new File("./aaa");*/  //重命名失败，因为该目录下已经存在aaa目录
        File file3 = new File("./ddd");
        File file4 = new File("./fff");
        System.out.println(file3.renameTo(file4));


        //用法二：转移
        //将file5指向的文件转移到file6指向的zzz目录下
        File file5 = new File("./z.text");
        File file6 = new File("./zzz/z.text");
        System.out.println(file5.renameTo(file6));
    }
}


